//=============================================================================
//
//   Copyright (C) 2020 All rights reserved.
//
//   Filename:		segment.rs
//
//   Author: Wang Zhecheng - wangzhecheng@yeah.net
//
//   Date: 2020-10-08 18:12
//
//   Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
//
//   Last modified:	2020-11-04 13:10
//
//   Description:
//
//=============================================================================
use crate::component::{gauss_point::GaussPoint, mesh_component::MeshComponentLike};
use crate::dimension::{DimType, HasDimension};
use crate::geometry::{integratable::Integratable, point::Point, shape::ShapeLike};
use crate::material::{HasMaterial, MaterialLike};
use crate::util::{Hashable, Indexable};
use nalgebra::dimension::Dim;
use std::collections::HashMap;
use std::rc::{Rc, Weak};

///
/// struct segment
///
#[derive(Debug)]
pub struct SegmentLinear<DT: DimType> {
    id: ,
    pt_list: Vec<Weak<Point<DT::Dim>>>,
    hash_key: String,
    gp_list: Vec<GaussPoint<DT>>,
    mat: Option<Weak<dyn MaterialLike<DT>>>,
    mesh: [HashMap<String, Weak<dyn MeshComponentLike<DT>>>; 4],
}

impl<DT: DimType> Default for Segment<DT> {
    fn default() -> Self {
        Self {
            id: -1 as i32,
            pt_list: Vec::new(),
            hash_key: String::new(),
            gp_list: Vec::new(),
            mat: None,
            mesh: [
                HashMap::new(),
                HashMap::new(),
                HashMap::new(),
                HashMap::new(),
            ],
        }
    }
}

element_like_impl!(Segment<DT: DimType>);

impl<DT: DimType> HasDimension for Segment<DT> {
    fn get_topo_dim(&self) -> usize {
        1usize
    }
    fn get_dim(&self) -> usize {
        DT::Dim::try_to_usize().expect("Failed to usize dimension")
    }
}
